﻿Imports Model
Imports Operation
Imports Helper
Imports Model.Geometry
Imports Model.Project
Imports fileio

Public Class MainForm

    Public CurrentProject As New MyProject()

    ''' <summary>
    ''' 窗体加载事件
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        '测试
        'Dim a
        'MsgBox(Double.TryParse("1258", a).ToString())
        'MsgBox(Path.GetDirectoryName(Path.GetFileName("project.pro")))
    End Sub

    ''' <summary>
    ''' 导入数据
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub import_Click(sender As System.Object, e As System.EventArgs) Handles import.Click
        If (CurrentProject Is Nothing) Then
            MsgBox("请打开或新建一个工程")
        Else
            Dim pubpath = CurrentProject.ProDir + "\" + CurrentProject.ProID + CurrentProject.ProName

            Dim name = DataAccess.importdata()
            If name IsNot Nothing Then
                FILEHelper.addptfile(name, pubpath)
                XMLHelper.addptElement(name, pubpath)
                PATHHelper.addptTreeView(My_Tree, name)
            Else
                Return
            End If
        End If
    End Sub

    ''' <summary>
    ''' 打开工程
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub OpenPro_Click(sender As System.Object, e As System.EventArgs) Handles OpenPro.Click
        Dim filename = DataAccess.openPro()
        If filename <> Nothing Then
            XMLHelper.readXML(filename, CurrentProject)
            FILEHelper.readFILE(CurrentProject)
            PATHHelper.setTreeView(My_Tree, CurrentProject)
            'MsgBox(CurrentProject.ProMidLine(0).endpt.p_y.ToString())
            cupro.Text = CurrentProject.ProID + " " + CurrentProject.ProName
        Else
            Return
        End If
    End Sub

    ''' <summary>
    ''' 上下文菜单事件
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub setCurr_Click(sender As System.Object, e As System.EventArgs) Handles setCurr.Click
        'cupro.Text = My_Tree.SelectedNode.Text
    End Sub

    ''' <summary>
    ''' 目录树鼠标右键事件
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub My_Tree_NodeMouseClick(sender As System.Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs)
        If e.Node Is My_Tree.Nodes(0) And e.Button = Windows.Forms.MouseButtons.Right Then
            e.Node.ContextMenuStrip = treecon
        End If
    End Sub

    ''' <summary>
    ''' 新建工程
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub newPro_Click(sender As System.Object, e As System.EventArgs) Handles newPro.Click
        Dim np = New NewProject()
        If (np.ShowDialog() = Windows.Forms.DialogResult.OK) Then
            PATHHelper.setTreeView(My_Tree, np.newpro)
            CurrentProject = np.newpro
            cupro.Text = CurrentProject.ProID + " " + CurrentProject.ProName
        End If
    End Sub

    ''' <summary>
    ''' 测试代码,直接拟合圆
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Test01_Click(sender As System.Object, e As System.EventArgs) Handles Test01.Click

        'Dim G As Graphics = sp01.Panel2.CreateGraphics()
        'G.TranslateTransform(sp01.Panel2.Width / 2, sp01.Panel2.Height / 2)
        'G.ScaleTransform(1, -1)
        'Dim P As Pen = New Pen(Drawing.Color.Black, 3)
        'Dim P2 As Pen = New Pen(Drawing.Color.Red, 3)
        'Dim C As New Circle()
        'Section.LS_CircleFitting(PubProject.proPTS, C)
        'P.DashStyle = Drawing.Drawing2D.DashStyle.Solid
        'P2.DashStyle = Drawing.Drawing2D.DashStyle.Dot

        'Dim x As Single = 25.1615
        'Dim y As Single = 105.0875
        'Dim w As Single = 61.767
        'Dim h As Single = 61.767
        'G.DrawEllipse(P, x, y, w, h)

        'Dim x1 As Single = C.center.p_x - C.radius
        'Dim y1 As Single = C.center.p_y + C.radius
        'Dim w1 As Single = C.radius * 2
        'Dim h1 As Single = C.radius * 2
        'G.DrawEllipse(P2, x1, y1, w1, h1)

    End Sub

    ''' <summary>
    ''' 测试代码,根据直线拟合圆,根据点获取面,根据面获取点,投影计算,带里程,求残差
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Test02_Click(sender As System.Object, e As System.EventArgs) Handles Test02.Click
        'Dim spt As New Point3d()
        'spt.p_x = 74.2079
        'spt.p_y = -5
        'spt.p_z = 56.0151
        'spt.p_flag = 0
        'Dim ept = New Point3d()
        'ept.p_x = 74.2079
        'ept.p_y = 5
        'ept.p_z = 56.0151
        'ept.p_flag = 0
        'Dim testline As New Mid_Line()
        'testline = BaseAccess.GetLine(spt, ept)
        'testline.startmileage = -5
        'testline.GetEndM()
        'Dim ptlist As New List(Of Point3d)()
        'Dim ptresult As New List(Of Point3d)()
        'Dim ptresult2 As New List(Of Point3d)()
        'Dim cir As New Circle()
        ''Dim currm As Single = testline.startmileage
        'Dim currm As Single = 0
        'Do
        '    ptlist.Clear()
        '    ptresult.Clear()
        '    ptresult2.Clear()
        '    Dim pt = BaseAccess.GetPointOnLine(currm, testline)
        '    Dim pl = BaseAccess.GetPlane(pt, testline)
        '    For i = 0 To PubProject.proPTS.Count - 1
        '        If Section.PointToPlane(pl, PubProject.proPTS(i)) < 1 Then
        '            ptlist.Add(PubProject.proPTS(i))
        '        End If
        '    Next
        '    If ptlist.Count < 300 Then
        '        currm = currm + 1
        '        If currm > testline.endmileage Then
        '            Exit Do
        '        End If
        '    Else
        '        For j = 0 To ptlist.Count - 1
        '            ptresult.Add(Section.ProjectionToPlane(pl, ptlist(j)))
        '        Next
        '        Section.SimpleCoord(testline, pt, ptresult, ptresult2)
        '        Section.LS_CircleFitting(ptresult2, cir)
        '        MsgBox(Math.Round((cir.center.p_x + 74.2079), 3).ToString() + "," + Math.Round(cir.center.p_y, 3).ToString() + "," + Math.Round(cir.radius, 3).ToString())
        '        Dim diserror As Double = 0
        '        For i = 0 To ptresult2.Count - 1
        '            diserror += Math.Pow((cir.center.GetDis3D(ptresult2(i))) - cir.radius, 2)
        '        Next
        '        diserror = Math.Round(Math.Sqrt(diserror), 4)
        '        MsgBox(diserror.ToString())
        '        currm = currm + 1
        '        If currm > testline.endmileage Then
        '            Exit Do
        '        End If
        '    End If
        'Loop
    End Sub

    ''' <summary>
    ''' 测试代码,直线为随机直线,根据直线拟合圆,根据点获取面,根据面获取点,投影计算,带里程
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Test03_Click(sender As System.Object, e As System.EventArgs) Handles Test03.Click
        'Dim spt As New Point3d()
        'spt.p_x = 540.7018
        'spt.p_y = -66.812
        'spt.p_z = 30.2751
        'spt.p_flag = 0
        'Dim ept = New Point3d()
        'ept.p_x = 609.3691
        'ept.p_y = 1.8553
        'ept.p_z = 30.2751
        'ept.p_flag = 0
        'Dim testline As New Line()
        'testline = BaseAccess.GetLine(spt, ept)
        'testline.startmileage = 60.1821
        'testline.GetEndM()
        'Dim ptlist As New List(Of Point3d)()
        'Dim ptresult As New List(Of Point3d)()
        'Dim ptresult2 As New List(Of Point3d)()
        'Dim cir As New Circle()
        ''Dim currm As Single = testline.startmileage
        'Dim currm As Single = 0
        'Do
        '    ptlist.Clear()
        '    ptresult.Clear()
        '    ptresult2.Clear()
        '    Dim pt = BaseAccess.GetPointOnLine(currm, testline)
        '    Dim pl = BaseAccess.GetPlane(pt, testline)
        '    For i = 0 To PubProject.proPTS.Count - 1
        '        If Section.PointToPlane(pl, PubProject.proPTS(i)) < 1 Then
        '            ptlist.Add(PubProject.proPTS(i))
        '        End If
        '    Next
        '    If ptlist.Count < 300 Then
        '        currm = currm + 1
        '        If currm > testline.endmileage Then
        '            Exit Do
        '        End If
        '    Else
        '        For j = 0 To ptlist.Count - 1
        '            ptresult.Add(Section.ProjectionToPlane(pl, ptlist(j)))
        '        Next
        '        Section.SimpleCoord(testline, pt, ptresult, ptresult2)
        '        Section.LS_CircleFitting(ptresult2, cir)
        '        MsgBox(Math.Round((cir.center.p_x + 74.2079), 3).ToString() + "," + Math.Round(cir.center.p_y, 3).ToString() + "," + Math.Round(cir.radius, 3).ToString())
        '        Dim diserror As Double = 0
        '        For i = 0 To ptresult2.Count - 1
        '            diserror += Math.Pow((cir.center.GetDis3D(ptresult2(i))) - cir.radius, 2)
        '        Next
        '        diserror = Math.Round(Math.Sqrt(diserror), 4)
        '        MsgBox(diserror.ToString())
        '        currm = currm + 1
        '        If currm > testline.endmileage Then
        '            Exit Do
        '        End If

        '        Dim str As String
        '        str = ptresult(0).p_x.ToString() + "；" + ptresult(0).p_y.ToString() + "；" + ptresult(0).p_z.ToString()
        '        str = str + vbCrLf + ptresult2(0).p_x.ToString() + "；" + ptresult2(0).p_y.ToString() + "；" + ptresult2(0).p_z.ToString()
        '        BaseAccess.GetTrueCoord(testline, ptresult2(0), pt)
        '        str = str + vbCrLf + ptresult2(0).p_x.ToString() + "；" + ptresult2(0).p_y.ToString() + "；" + ptresult2(0).p_z.ToString()
        '        MsgBox(str)
        '    End If


        'Loop
    End Sub

    ''' <summary>
    ''' 测试,打开CAD绘制断面图
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Test04_Click(sender As System.Object, e As System.EventArgs) Handles Test04.Click
        ''将绘制代码写进scr文件中
        'Dim scr_name As String = "C:\Users\Administrator\Desktop\创新课题\vbresearch\AlgorithmResearch\AlgorithmResearch\bin\Debug\drawcircle.scr"
        ''Dim fw As New FileStream(scr_name, FileMode.Create, FileAccess.ReadWrite)
        ''Dim sr As New StreamReader(scr_name, Encoding.UTF8)
        ''Dim sw As New StreamWriter(fw, Encoding.UTF8)
        ' ''打开cad程序,执行scr文件绘制断面图形
        'Dim cadApp As New AcadApplicationClass()
        'Dim newProc1 As Process = Process.Start(cadApp.FullName, "/t /b " + scr_name)
        'On Error GoTo 0

        'Dim acad As Object
        'Dim acad As AutoCAD.Interop.AcadApplication
        'On Error Resume Next
        'acad = GetObject(, "AutoCAD.Application")
        'If Err.Number Then
        '    Err.Clear()
        '    acad = CreateObject("AutoCAD.Application.16.2")
        '    'acad = New AutoCAD.Interop.AcadApplication
        '    If Err.Number Then
        '        MsgBox(Err.Description)

        '        Exit Sub
        '    End If
        'End If
        'acad.Visible = True

        'CADHelper.GetAcadApplication()

        Dim c(0 To 2) As Double
        c(0) = 1103
        c(1) = 658
        c(2) = 0
        ''绘制圆
        'Dim MyCircle As Object = acad.ActiveDocument.ModelSpace.AddArc(c, 8, 3.14, Math.PI / 4)
        'Dim MyCircle As AcadCircle = acad.ActiveDocument.ModelSpace.AddArc(c, 8, 3.14, Math.PI / 4)
        ' ''设置对象的颜色
        'MyCircle.color = ACAD_COLOR.acRed
        ' ''全部缩放
        'Dim aa = acad.ActiveDocument.ModelSpace.AddMText(c, 6.5, "r=7.01")

        'Dim bb = acad.ActiveDocument.TextStyles.Add("texttext1")
        'bb.SetFont("Times New Roman", False, False, 0, 0)
        'acad.ActiveDocument.ActiveTextStyle = bb
        'Dim aa = acad.ActiveDocument.ModelSpace.AddText("r=7.01", c, 5)
        'aa.Rotation = 3 * Math.PI / 2
        'acad.ZoomAll()
        ' ''重新绘制模型
        'acad.ActiveDocument.Regen(AcRegenType.acActiveViewport)
        ' ''缩放到范围
        'acad.ZoomExtents()
        ''MsgBox(MyCircle.color.ToString)
        'acad.ActiveDocument.ActiveLayer.color = AcColor.acYellow
        'acad.ActiveDocument.ModelSpace.AddCircle(c, 5)
        ''MsgBox(acad.ActiveDocument.ActiveLayer.Name)
        ''MsgBox(acad.ActiveDocument.Name)
        'Dim p(0 To 2) As Double
        'p(0) = 10
        'p(1) = 10
        'p(2) = 0
        ' ''设置系统变量改变点的样式和大小
        'acad.ActiveDocument.SetVariable("PDMODE", 34)
        'acad.ActiveDocument.SetVariable("PDSIZE", 0.5)
        'Dim pt As AcadPoint
        'pt = acad.ActiveDocument.ModelSpace.AddPoint(p)
        'acad = Nothing
    End Sub

    ''' <summary>
    ''' 测试，坐标反算过程
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub 测试坐标反算ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles 测试坐标反算ToolStripMenuItem.Click
        'Dim spt As New Point3d()
        'spt.p_x = 10
        'spt.p_y = 10
        'spt.p_z = 10
        'spt.p_flag = 0
        'Dim ept = New Point3d()
        'ept.p_x = -3.1962
        'ept.p_y = -18.1755
        'ept.p_z = 10
        'ept.p_flag = 0
        'Dim testline As New Line()
        'testline = BaseAccess.GetLine(spt, ept)
        'testline.startmileage = 0
        'testline.GetEndM()
        'Dim ptlist As New List(Of Point3d)()
        'Dim ptresult As New List(Of Point3d)()
        'Dim ptresult2 As New List(Of Point3d)()
        'Dim cir As New Circle()
        ''Dim currm As Single = testline.startmileage
        'Dim currm As Single = 3.5355
        'Do
        '    ptlist.Clear()
        '    ptresult.Clear()
        '    ptresult2.Clear()
        '    Dim pt = BaseAccess.GetPointOnLine(currm, testline)
        '    Dim pl = BaseAccess.GetPlane(pt, testline)
        '    For i = 0 To PubProject.proPTS.Count - 1
        '        If Section.PointToPlane(pl, PubProject.proPTS(i)) < 1 Then
        '            ptlist.Add(PubProject.proPTS(i))
        '        End If
        '    Next
        '    If ptlist.Count = 0 Then
        '        currm = currm + 1
        '        If currm > testline.endmileage Then
        '            Exit Do
        '        End If
        '    Else
        '        For j = 0 To ptlist.Count - 1
        '            ptresult.Add(Section.ProjectionToPlane(pl, ptlist(j)))
        '        Next
        '        Section.SimpleCoord(testline, pt, ptresult, ptresult2)
        '        'Section.LS_CircleFitting(ptresult2, cir)
        '        'MsgBox(Math.Round((cir.center.p_x + 74.2079), 3).ToString() + "," + Math.Round(cir.center.p_y, 3).ToString() + "," + Math.Round(cir.radius, 3).ToString())
        '        'Dim diserror As Double = 0
        '        'For i = 0 To ptresult2.Count - 1
        '        '    diserror += Math.Pow((cir.center.GetDis3D(ptresult2(i))) - cir.radius, 2)
        '        'Next
        '        'diserror = Math.Round(Math.Sqrt(diserror), 4)
        '        'MsgBox(diserror.ToString())
        '        currm = currm + 1
        '        If currm > testline.endmileage Then
        '            Exit Do
        '        End If

        '        Dim str As String
        '        str = ptresult(0).p_x.ToString() + "；" + ptresult(0).p_y.ToString() + "；" + ptresult(0).p_z.ToString()
        '        str = str + vbCrLf + ptresult2(0).p_x.ToString() + "；" + ptresult2(0).p_y.ToString() + "；" + ptresult2(0).p_z.ToString()
        '        BaseAccess.GetTrueCoord(testline, ptresult2(0), pt)
        '        str = str + vbCrLf + ptresult2(0).p_x.ToString() + "；" + ptresult2(0).p_y.ToString() + "；" + ptresult2(0).p_z.ToString()
        '        MsgBox(str)
        '    End If


        'Loop
    End Sub

    Private Sub ToolStripButton4_Click(sender As System.Object, e As System.EventArgs)
        'Me.NotifyIcon1.Visible = True
        'Me.NotifyIcon1.ShowBalloonTip(1000, "好的", DateTime.Now.ToLocalTime().ToString(), ToolTipIcon.Info)
    End Sub

    ''' <summary>
    ''' 测试圆曲线坐标点及方位角计算公式的正确性,通过测试
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub TestCircle01ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles TestCircle01ToolStripMenuItem.Click
        Dim circleline As New Midline.Mid_Circle()
        circleline.startpt.p_x = 3.6313
        circleline.startpt.p_y = 2.7482
        circleline.endpt.p_x = 7.1489
        circleline.endpt.p_y = 9.1853
        circleline.length = 9.2838
        circleline.startm = 1
        circleline.endm = 10.2838
        circleline.isturnright = True
        circleline.startOri.V_x = -1.6032
        circleline.startOri.V_y = +2.0646
        circleline.radius = 4
        'circleline.initMyself()
        circleline.startOri.GetAzimuth()
        Dim vec As New SingleVector()
        Dim pt = circleline.GetPointByMileage(5.6419, vec)
        MsgBox("里程5.6419处点坐标：" + pt.p_x.ToString() + "," + pt.p_y.ToString() + vbCr + "方向：" + vec.V_x.ToString() + "," + vec.V_y.ToString())
    End Sub

    ''' <summary>
    ''' 测试缓和曲线坐标点及方位角的计算公式正确性，通过测试
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub TestCircle01ToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) Handles TestCircle01ToolStripMenuItem1.Click
        Dim circleline As New Midline.Mid_SuperCircle()
        circleline.startpt.p_x = 806.6155
        circleline.startpt.p_y = 506.993
        circleline.endpt.p_x = 882.7353
        circleline.endpt.p_y = 531.5313
        circleline.length = 80
        circleline.startm = 1
        circleline.endm = 81
        circleline.isturnright = True
        circleline.startOri.V_x = 83.9751
        circleline.startOri.V_y = 29.5645
        circleline.startRadius = 0
        circleline.endRadius = 500

        circleline.startOri.GetAzimuth()
        Dim vec As New SingleVector()
        Dim pt = circleline.GetPointByMileage(41, vec)
        MsgBox(String.Format("里程5.6419处点坐标：{0},{1}{2}方向：{3},{4},{5}", pt.p_x, pt.p_y, vbCr, vec.V_x, vec.V_y, vec.Azi))
    End Sub

    ''' <summary>
    ''' 菜单-断面拟合-圆形
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub CircleFit_Click(sender As System.Object, e As System.EventArgs) Handles 圆形隧道ToolStripMenuItem.Click
        If CurrentProject.ProID = "空" Then
            MsgBox("请先打开或创建一个工程", , "提示")
            Return
        Else
            Dim mycircle As New MyControlCircle(CurrentProject)
            sp_02.Panel1.Controls.Clear()
            sp_02.Panel1.Controls.Add(mycircle)
            mycircle.Dock = DockStyle.Fill
            If (mycircle.flag = 1) Then
                PATHHelper.addResultTreeView(My_Tree, mycircle.resultlist, True, True, mycircle.currtime)
            End If
        End If
    End Sub

    ''' <summary>
    ''' 开始执行圆形隧道的拟合
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Execute_Click(sender As System.Object, e As System.EventArgs)

    End Sub

    ''' <summary>
    ''' 取消该操作
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub Cancel_Click(sender As System.Object, e As System.EventArgs)

    End Sub

    Private Sub TestCircle01ToolStripMenuItem2_Click(sender As System.Object, e As System.EventArgs) Handles TestCircle01ToolStripMenuItem2.Click
        CurrentProject.VLine.bpdlist(0).initMySelf()
        Dim aa = New test()
        If aa.ShowDialog() = Windows.Forms.DialogResult.OK Then
            MsgBox(CurrentProject.VLine.GetEleByMileage(aa.mil).ToString())
        End If

    End Sub

    Private Sub 测试坐标点计算ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles 测试坐标点计算ToolStripMenuItem.Click

    End Sub

    Private Sub 测试excelToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles 测试excelToolStripMenuItem.Click
        'EXCELHelper.GetExcelApplication()
    End Sub

    Private Sub HorseFit_Click(sender As System.Object, e As System.EventArgs) Handles HorseFit.Click
        If CurrentProject.ProID = "空" Then
            MsgBox("请先打开或创建一个工程", , "提示")
            Return
        Else
            Dim myhorse As New MyControlHorse(CurrentProject)
            sp_02.Panel1.Controls.Clear()
            sp_02.Panel1.Controls.Add(myhorse)
            myhorse.Dock = DockStyle.Fill
            'If (myhorse.flag = 1) Then
            '    PATHHelper.addResultTreeView(My_Tree, myhorse.resultlist, True, True, myhorse.currtime)
            'End If
        End If
    End Sub

    Private Sub 方形隧道ToolStripMenuItem1_Click(sender As System.Object, e As System.EventArgs) Handles 方形隧道ToolStripMenuItem1.Click
        If CurrentProject.ProID = "空" Then
            MsgBox("请先打开或创建一个工程", , "提示")
            Return
        Else
            Dim myrec As New MyControlRectangle(CurrentProject)
            sp_02.Panel1.Controls.Clear()
            sp_02.Panel1.Controls.Add(myrec)
            myrec.Dock = DockStyle.Fill
            'If (myhorse.flag = 1) Then
            '    PATHHelper.addResultTreeView(My_Tree, myhorse.resultlist, True, True, myhorse.currtime)
            'End If
        End If
    End Sub

    Private Sub My_Tree_NodeMouseClick_1(sender As System.Object, e As System.Windows.Forms.TreeNodeMouseClickEventArgs) Handles My_Tree.NodeMouseClick
        If e.Button = Windows.Forms.MouseButtons.Right Then

            Select Case e.Node.Tag.ToString()
                Case "root"
                    My_Tree.ContextMenuStrip = treecon
                Case "first"
                    My_Tree.ContextMenuStrip = treecon1
                Case "second"
                    My_Tree.ContextMenuStrip = treecon2
                    treecon2.Items(0).Enabled = True
                    treecon2.Items(1).Enabled = False
                Case "childpt"
                    My_Tree.ContextMenuStrip = treecon2
                    treecon2.Items(0).Enabled = False
                    treecon2.Items(1).Enabled = True
                Case Else
                    My_Tree.ContextMenuStrip = Nothing
            End Select

        End If
    End Sub

    Private Sub 打开帮助文件ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles 打开帮助文件ToolStripMenuItem.Click
        '打开帮助文集
    End Sub

    Private Sub 关于ToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles 关于ToolStripMenuItem.Click
        '关于对话框
        Dim about As New About()
        about.Show()
    End Sub

    Private Sub TestfileioToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles TestfileioToolStripMenuItem.Click
        Dim tfio = New TextFileIO
        tfio.outputdata()
    End Sub
End Class
